<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of kickoffplayer
 *
 * @author Samuel
 */


class kickoffplayer_Controller Extends Controller {
	
	private $areaList;	//区号列表
	
	function _init() 
	{
        check_level(50, segment(0), segment(1), segment(2, 'index'));
        
    	//区名信息
    	$sql = "SELECT *  FROM {pre}areasample ";
        $this->db->query($sql);
        //echo "sql:$sql";
    	while ($n = $this->db->get_array('default')) 
    	{
    		//print_r($n);
            $this->areaList[$n['id']]['name']=$n['name']; 
            $this->areaList[$n['id']]['host']=$n['host'];  
        } 
        //print_r($this->strategyList);
    	if(0 == count($this->areaList)) 
     	{
            echo "<script>alert('" . translate('C_ADD_AREA') . "');</script>";
            return;
        }
	}
	
    //put your code here
    function index() {
        if (is_submit()) {
            $rowdate = $_POST['row'];
            //print_r($rowdate);
            $rowdate['area_host'] = $this->areaList[$rowdate['area']]['host'];
            $url = $rowdate['area_host'] . "role_name=" . $rowdate['role_name']
            	.'&seal_time='.$rowdate['seal_time']."&role_id=".$rowdate['role_id']. "&action=5";
            //echo($url);
            $strResult = vpost($url);
            //echo "strresutl = $strResult url = $url ";
           if(0 == $strResult)
           {
           		//echo 'success';
           		//cp_tips("success");
           		insert_log(translate('MENU_SEAL_KICKOFFPLAYER'), translate('ADD'), NULL, array("name"=>$rowdate['role_name']));
           		echo "<script>alert('".translate('C_TIPS_SUCCESS_TEXT')."')</script>";
           }
           else 
           {
           		//echo 'fail...';
           		//cp_tips("error");
           		echo "<script>alert('".translate('C_TIPS_ERROR_TEXT')."')</script>";
           }
        } 
	    //$this->view->assign("arealist", $this->form->select("row[area_host]", get_area_list_host(), '', array('id' => 'area_host')));
	    $this->view->assign("areaList", $this->areaList);
	    $this->view->display("seal/kickoffplayer/index");
        
    }
}

?>
